<template>
	<view class="content">
		<uamhead :title="title"></uamhead>
		<view class="index-search" @tap="navSearch">
			<text class="iconfont iconsearch"></text><input type="text" value="" placeholder="搜索歌曲" />
		</view>
		<scroll-view scroll-y="true" >
			<view>
				<m-for-skeleton
				:avatarSize="200"
				:row="3"
				:title="false"
				:loading="loading"
				isarc="square"
				:titleStyle="{}"
				v-for="(item,key) in 4"
				:key="key">
				</m-for-skeleton>
			</view>

			<view class="index-list" v-for="(item,index) in playlist" :key="index" @click="handleNavtoList(item.id)">
				<view title="" note="" class="index-list-item">
					<view  class="index-list-img">
						<image :src="item.coverImgUrl"></image>
						<text>{{item.updateFrequency}}</text>
					</view>
					<view class="index-list-text">
						<view  v-for="(musicItem,index) in item.tracks" :key="index">
							{{index+1}}.{{musicItem.first}}-{{musicItem.second}}
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import { topList} from '../../common/api.js'
	export default {
		data() {
			return {
				playlist:[],
				title: '歌单',
				loading: true,
			}
		},
		onLoad() {
			const baseUrlObj=uniCloud.importObject('BaseUrl');
			baseUrlObj.Get().then(res =>{console.log(res)});
			topList().then((res)=>{

				setTimeout(()=>{
					this.playlist=res.data.list.slice(0,4);
					this.loading=false;
				},1000)
				// this.playlist=res.data.list.slice(0,4);
						});
		},
		methods: {
			handleNavtoList(id){
				uni.navigateTo({
					url: '/pages/list/list?listid='+id,
				});
			},
			navSearch(){
				uni.navigateTo({url: '/pages/search/search'})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	
	.index-list{ margin:30rpx 30rpx 30rpx 30rpx;;width: 95%}
	.index-list-item{ display: flex; margin-bottom: 35rpx;}
	.index-list-img{ width:212rpx; height:212rpx; margin-right:20rpx; border-radius: 15rpx; overflow: hidden; position: relative;}
	.index-list-img image{ width:100%; height:100%;}
	.index-list-img text{ position: absolute; font-size:22rpx; color:white; bottom: 15rpx; left:15rpx;}
	.index-list-text{ flex:1; font-size:24rpx; line-height: 68rpx;}
	.index-list-text view{}
	.index-search text{ margin:0 27rpx;} 
	.index-search input{ font-size:26rpx; flex:1;}
</style>
